/*    */ package com.zimbra.cs.index.query;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ import java.util.Set;
/*    */ import org.apache.lucene.analysis.Analyzer;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public final class MeQuery
/*    */   extends SubQuery
/*    */ {
/*    */   private MeQuery(List<Query> clauses)
/*    */   {
/* 39 */     super(clauses);
/*    */   }
/*    */   
/*    */   public static Query create(Mailbox mbox, Analyzer analyzer, Set<AddrQuery.Address> addrs) throws ServiceException {
/* 43 */     List<Query> clauses = new ArrayList();
/* 44 */     Account acct = mbox.getAccount();
/* 45 */     if (addrs.contains(AddrQuery.Address.FROM)) {
/* 46 */       clauses.add(new SentQuery(true));
/*    */     }
/* 48 */     if (addrs.contains(AddrQuery.Address.TO)) {
/* 49 */       if (!clauses.isEmpty()) {
/* 50 */         clauses.add(new ConjQuery(ConjQuery.Conjunction.OR));
/*    */       }
/* 52 */       clauses.add(new TextQuery(analyzer, "to", acct.getName()));
/*    */     }
/* 54 */     if (addrs.contains(AddrQuery.Address.CC)) {
/* 55 */       if (!clauses.isEmpty()) {
/* 56 */         clauses.add(new ConjQuery(ConjQuery.Conjunction.OR));
/*    */       }
/* 58 */       clauses.add(new TextQuery(analyzer, "cc", acct.getName()));
/*    */     }
/*    */     
/* 61 */     for (String alias : acct.getMailAlias()) {
/* 62 */       if (addrs.contains(AddrQuery.Address.TO)) {
/* 63 */         if (!clauses.isEmpty()) {
/* 64 */           clauses.add(new ConjQuery(ConjQuery.Conjunction.OR));
/*    */         }
/* 66 */         clauses.add(new TextQuery(analyzer, "to", alias));
/*    */       }
/* 68 */       if (addrs.contains(AddrQuery.Address.CC)) {
/* 69 */         if (!clauses.isEmpty()) {
/* 70 */           clauses.add(new ConjQuery(ConjQuery.Conjunction.OR));
/*    */         }
/* 72 */         clauses.add(new TextQuery(analyzer, "cc", alias));
/*    */       }
/*    */     }
/* 75 */     return new MeQuery(clauses);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/index/query/MeQuery.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */